package com.vallis.asfc.controller;


import cn.hutool.core.util.IdcardUtil;
import com.vallis.asfc.entity.Organization;
import com.vallis.asfc.entity.User;
import com.vallis.asfc.service.HxTeamService;
import com.vallis.asfc.service.OrganizationService;
import com.vallis.asfc.util.NativePlace;
import com.vallis.asfc.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author vallis
 * @since 2020-07-22
 */
@Controller
@RequestMapping("/hx-team")
public class HxTeamController {

    @Autowired
    private HxTeamService hxTeamService;
    @Autowired
    private OrganizationService organizationService;
    
    @GetMapping("/doIni")
    public Result doIni(){
        System.out.println("单位执行");
        System.out.println(hxTeamService.list().size());
        hxTeamService.list().forEach(item->{
            System.out.println(item);
            Organization o=new Organization();
            o.setId((long)item.getId())
                    .setOrgName(item.getFullName())
                    .setOrgSn(item.getSn())
                    .setOrgAddress(item.getAddress())
                    .setOrgCity(item.getCity())
                    .setCreaterUser((long)1);
            if (item.getOrgType().equals("Q")){
                o.setOrgType(3);
            }else if (item.getOrgType().equals("H")){
                o.setOrgType(1);
            }else if(item.getOrgType().equals("X")){
                o.setOrgType(2);
            }else {
                o.setOrgType(0);
            }
            if(item.getStatus()==2){
                o.setOrgState((long)1);
            }else {
                o.setOrgState((long)0);
            }
            
            boolean save = organizationService.save(o);
            System.out.println(save);
            
                }
        
        
               
        
        
        
        );
        System.out.println("执行完毕");
        return new Result(new String("success"));
    }
}
